﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;

namespace BabyShop.Site.Exts.Extensions
{
    public static class EnumExtension
    {
        public static Dictionary<int, string> ConvertEnumToDictionary<T>()
        {
            Type enumObjType = typeof (T);
            string[] enumNames = Enum.GetNames(enumObjType);
            int[] enumValues = Enum.GetValues(enumObjType) as int[];
            Dictionary<int, string> enumDic = new Dictionary<int, string>();
            if(enumValues != null)
                for (int i = 0; i < enumNames.Length; i++) {
                    enumDic[enumValues[i]] = enumNames[i];
                }

            return enumDic;
        }
    }
}